//
//  NewMessageJiangLiViewController.m
//  wangzhe
//
//  Created by 李 佳伟 on 2018/3/22.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "NewMessageJiangLiViewController.h"
#import "JTCSM.h"
#import "HuankuanJiluTableViewCell.h"
#import "HuiYuanModel.h"
@interface NewMessageJiangLiViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSString *mykeyword;
}
@property (nonatomic,strong) NSMutableArray *titlearray;
@property (nonatomic,strong) UITableView *tableview;
@property (nonatomic,strong) NSMutableArray *datascoureArray;
@end

@implementation NewMessageJiangLiViewController
- (void)getDatasourceArray{
    NSArray *titlearray   = @[@"星星点灯",@"分享奖励",@"互动奖励"];
    NSArray *contentarray = @[@"年轻人，别总把没意思挂在嘴边",@"年轻人，别总把没意思挂在嘴边",@"年轻人，别总把没意思挂在嘴边"];
    NSArray *imagearray   = @[@"星星icon.png",@"分享奖励.png",@"互动奖励.png"];
    _datascoureArray = [NSMutableArray arrayWithCapacity:2];
    for (int i = 0; i<titlearray.count; i++) {
        HuiYuanModel *Model = [[HuiYuanModel alloc]init];
        Model.huiyuanTitle = titlearray[i];
        Model.huiyuanfooterTitle = contentarray[i];
        Model.huiyuanImageName = imagearray[i];
        [_datascoureArray addObject:Model];
    }
}
- (void)gotBack{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = NO;
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [df isRemoveTarbar:YES];
    self.navigationController.navigationBar.hidden = NO;
    self.view.backgroundColor =[UIColor whiteColor];
    leftBarButtonItems_rightBarButtonItems *leftbtn = KCUSTOMNAVIGSTION_ALLOC;
    self.navigationItem.leftBarButtonItem = [leftbtn setBarButtonItemsImageName:@"fanhui.png" frame:KLeftBarButtonItemFrame_image target:self SEL:@selector(gotBack)];
    // Do any additional setup after loading the view.
    [self layoutTableView];
}
- (void)layoutTableView{
    [df newlineViewWithHeightofTop:10 superView:self.view  spacing:0 color:RGBACOLOR(241, 241, 241, 1) lineHeight:10];
    [self getDatasourceArray];
    _tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 10, KCONTROLLERWith, KCONTROLLERHeight-10) style:UITableViewStylePlain];
    _tableview.delegate = self;
    _tableview.dataSource = self;
    [self.view addSubview:_tableview];
    _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self setUpTableView];
    //    view.backgroundColor = RGBACOLOR(241, 241, 241, 1);
}

- (void)setUpTableView{
    // 1.下拉刷新(进入刷新状态就会调用self的headerRereshing)
    [_tableview addHeaderWithTarget:self action:@selector(headerRereshing)];
    
    // 上拉加载
    [_tableview addFooterWithTarget:self action:@selector(footerRereshing)];
    
}
- (void)headerRereshing{
    // 2秒后刷新表格UI
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(KRefreshTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        //getMarriageSeeking(网络请求)
        //        [self theRequestWithKeyWord:mykeyword];
    });
}
- (void)footerRereshing{
    // 2秒后刷新表格UI
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(KRefreshTime * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        //getMarriageSeeking(网络请求)
        //        [self loadMoreDataRequestWithKeyWord:mykeyword];
        
    });
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _datascoureArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *cellid = [NSString stringWithFormat:@"textfield%ld",(long)indexPath.row];
    HuankuanJiluTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid];
    if (cell == nil) {
        cell = [[HuankuanJiluTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid cellType:indexPath.row == 0?IsButtonType:IsZhangDanType];
    }
    [cell setValueWithModel:indexPath];
    HuiYuanModel *model = _datascoureArray[indexPath.row];
    cell.titleLabel.text = model.huiyuanTitle;
    cell.timeLabel.text = model.huiyuanfooterTitle;
    cell.logoImageView.image = [UIImage imageNamed:model.huiyuanImageName];
    
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 75;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
